package com.hengpeng.itfints.constants;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.hengpeng.common.cis.ComponentContextLoader;
import com.hengpeng.common.exception.ServiceResult;
import com.hengpeng.itfinbase.persist.SystemConfig;
import com.hengpeng.itfints.service.SystemConfigService;

/**
 * <pre>
 * 读取系统参数
 * </pre>
 * @author chenjian
 * @version 1.0, 2012-5-28
 */
public class SystemConfigUtil
{
	private final static Log logger = LogFactory.getLog(SystemConfigUtil.class);

	private static SystemConfigService configService = ComponentContextLoader.getBean(SystemConfigService.class);

	public static String getConfigValue(String key)
	{
		try
		{
			ServiceResult<SystemConfig> sr = configService.findById(key);
			if (sr.getReturnValue() == null)
			{
				logger.error("系统参数{" + key + "}不存在!");
			}
			return sr.getReturnValue() == null ? null : sr.getReturnValue().getValue();
		}
		catch (Exception e)
		{
			return null;
		}
	}
}
